package org.zy;

import org.zy.model.Test1;
import org.zy.thread.RunnableDemo;
import org.zy.thread.ThreadDemo;

/**
 * @author Zhang Yu
 * @description: TODO
 * @date 2024/4/24 16:23
 */
public class TestThread {
    public static void main(String[] args) throws InterruptedException {
//        runnableTest();
        threadTest();
        Thread.sleep(2000);
        System.out.println("Test1.count = " + Test1.count);
    }

    private static void threadTest() throws InterruptedException {
        ThreadDemo t1 = new ThreadDemo( "Thread-1");
        ThreadDemo t2 = new ThreadDemo( "Thread-2");
        t1.start();
        t2.start();
        t1.join();
        t2.join();
    }

    private static void runnableTest() {
        RunnableDemo r1 = new RunnableDemo("thread-1");
        r1.start();
        RunnableDemo r2 = new RunnableDemo("thread-2");
        r2.start();
    }
}
